package com.geline.demo.config;

import cn.hutool.core.bean.BeanUtil;
import com.geline.demo.entity.ExcelFile;
import com.geline.demo.mapper.ExcelFileMapper;
import com.geline.easyexcel.domain.ExcelFileEntity;
import com.geline.easyexcel.interfaces.ExcelFileDao;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * ExcelFile文件表操作
 *
 * @author: mengxin
 * @date: 2024/1/25 10:38
 */
@Component
public class MyExcelFileDao implements ExcelFileDao {

    @Resource
    private ExcelFileMapper excelFileMapper;

    @Override
    public ExcelFileEntity save(ExcelFileEntity entity) {
        ExcelFile bean = BeanUtil.toBean(entity, ExcelFile.class);
        excelFileMapper.insert(bean);
        return BeanUtil.toBean(bean, ExcelFileEntity.class);
    }

    @Override
    public ExcelFileEntity getById(Serializable id) {
        ExcelFile bean = excelFileMapper.selectById(id);
        return BeanUtil.toBean(bean, ExcelFileEntity.class);
    }
}
